package cn.lczze.stock.service.impl;


import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.time.DayOfWeek;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.TextStyle;
import java.util.Locale;


/**
 * 仿真引擎
 */
@Slf4j
@Data
public class TimeEngineThread extends Thread {


	private String runTime = "";

	private int i = 0;
	@Override
	public void run() {
		try {
			Thread.sleep(1000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		log.info("currentTime:::" + 123);

		for (;;) {
			try {
				Thread.sleep(1000);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
			i++;
			System.out.println(i);


			// 获取当前系统时间
			LocalDateTime now = LocalDateTime.now();

			// 定义你想要的时间格式
			DateTimeFormatter dayFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd");


			DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
			DayOfWeek dayOfWeek = now.getDayOfWeek();
			int hour = now.getHour();

			// 格式化当前时间
			String formattedDate = now.format(formatter);
			String week = dayOfWeek.getDisplayName(TextStyle.NARROW, Locale.CHINA);
			// 打印格式化后的时间
			System.out.println("当前系统时间: " + formattedDate);

			log.info("周{}, 小时：{}",week, hour);
		}

	}


}
